namespace cpputils
{

class logger : private noncopyable
{
public:
	enum level { all_level, finest_level, finer_level, fine_level, config_level, info_level, warning_level, severe_level, off_level };

	struct task
	{
	public:
		task(logger* SetLogger = 0);
		task(const task& Val);
		~task();
		task& operator=(const task& Val);
		void begin(logger* SetLogger);
		void end();
		const string& get_progress();
		void progress(const string& S);

	private:
		mutable logger* Logger;
		mutable string Progress;
	};

	static const string& get_level_name(level Lev);

	logger(FILE* SetFile = 0);
	FILE* get_file() const;
	void set_file(FILE* Val);
	level get_level() const;
	void set_level(level Val);
	int get_indent() const;
	void set_indent(int Val);
	void indent(int Val);
	void unindent(int Val);
	task log(level MsgLevel, const string& S);
	task severe(const string& S);
	task warning(const string& S);
	task info(const string& S);
	task config(const string& S);
	task fine(const string& S);
	task finer(const string& S);
	task finest(const string& S);

private:
	FILE* File;
	level Level;
	int Indent;
	int ProgressLen;

	void progress(const string& S);
	void clear_progress();
};

logger* nillogger();
logger* clogger();

}
